What is the Python equivalent of Perl's chomp function, which removes the last character of a string if it is a newline? ... The canonical way to strip end-of-line (EOL) characters is to use the string rstrip() method removing any trailing \r or &